const { resolve } = require('path')

const baseConfig = require('./webpack.base')

const devConfig = {
  entry: baseConfig.entry,
  output: {
    ...baseConfig.output
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        oneOf: [
          ...baseConfig.commonRules,
          {
            test: /\.css$/,
            use: [
              'style-loader',
              'css-loader',
              'postcss-loader'
            ]
          },
          {
            test: /\.less$/,
            use: [
              'style-loader',
              'css-loader',
              'postcss-loader',
              'less-loader'
            ]
          }
        ]
      }
    ]
  },
  plugins: [
    ...baseConfig.commonPlugins,
  ],
  // 模块依赖
  resolve: baseConfig.commonResolve,
  // 优化 -- 代码分割
  optimization: baseConfig.commonOptimization,
  // 代码映射
  devtool: 'eval-source-map',
  devServer: {
    compress: true,
    port: 3000,
    open: true,
    hot: true,
    proxy: baseConfig.proxy
  },
  mode: 'development'
}

module.exports = devConfig;
